import load from '@/utils/jsapi.js';
const threeoperate = {
 async flashpoints(Parameters) {
    const [
      AEJsonRenderer,
      THREERendererManager,
    ] = await load([
      "extensions/threeRenderer/AEJsonRenderer",
      "extensions/esri/THREERendererManager",
    ]);
    if (window.ThreeManager == undefined || window.ThreeManager == null) {
      window.ThreeManager = new THREERendererManager(window.sceneView);
      window.AEJsonRenderer = new AEJsonRenderer(window.sceneView);
      window.ThreeManager.add(window.AEJsonRenderer);
    }

    const params = $.extend({
      visible: true,
      data: [],
      geofield: {
        xfield: "x",
        yfield: "y",
        zfield: "z"
      }
    }, Parameters);



    if (!params.visible) {
      window.AEJsonRenderer.clear();
    }

    var gs = [];
    params.data.forEach(function (item) {
      gs.push({
        geometry: {
          x: Number(item[params.geofield.xfield]),
          y: Number(item[params.geofield.yfield]),
          z: item[params.geofield.zfield] || 0.1
        },
        attributes: item
      });
    })
    window.AEJsonRenderer.add(gs, {
      size: 16
    });

    // dataprase.then(function (data) {
    //   var gs = [];
    //   data.forEach(function (item) {
    //     gs.push({
    //       geometry: {
    //         x: Number(item[params.geofield.xfield]),
    //         y: Number(item[params.geofield.yfield]),
    //         z: item[params.geofield.zfield] || 0.1
    //       },
    //       attributes: item
    //     });
    //   })
    //   window.AEJsonRenderer.add(gs, {
    //     size: 16
    //   });
    // });
  }
}
export default threeoperate
